<%-- 
    Document   : UpdateProjectInfo
    Created on : Jul 22, 2011, 8:25:17 AM
    Author     : sugia
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="ProjectMgtSystem.Entities.*" %>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta http-equiv="Content-Style-Type" content="text/css" />
        <link href="css/style1.css" rel="stylesheet" type="text/css" />
        <link href="css/layout.css" rel="stylesheet" type="text/css" />     
        <script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
             <script type="text/javascript" src="js/ui.core.js"></script>
        <script type="text/javascript" src="js/ui.datepicker.js"></script>
    </head>
    <script type="text/javascript">
        //define function to be executed on document ready
          $(function(){

            //create the date picker
            $("#pSD").datepicker();
            $("#pED").datepicker();
          });
    
        function isValidDate(sText) {
            var reDate = /(?:0[1-9]|1[0-2])\/(?:0[1-9]|[12][0-9]|3[01])\/(?:19|20\d{2})/;
            return reDate.test(sText);
        }
        
        function validateForm()
        {            
            var z= $("#Name").val();
            var pSD= $("#pSD").val();           
            var pED= $("#pED").val();           
            var msgErr ="";           
            if (z==null || z=="")
            {
                msgErr = msgErr + "\nTask Name must be filled out.";                
            }   
            if (pSD=="" || !isValidDate(pSD) || pSD.toString().length != 10)
            {
                msgErr = msgErr + "\nPlan Start Date is invalid.";                
            }
            if (pED=="" || !isValidDate(pED) || pED.toString().length != 10)
            {
                msgErr = msgErr + "\nPlan End Date is invalid.";                
            }
            var strSDate = pSD.split("/"); 
            var strEDate = pED.split("/"); 
            var pSDate = parseInt(strSDate[2]+strSDate[0]+strSDate[1], 10);                
            var pEDate = parseInt(strEDate[2]+strEDate[0]+strEDate[1], 10);
            if(pSDate > pEDate){
                 msgErr = msgErr + "\nPlan Start Date is greater than Plan End Date.";                
            }   
            if(msgErr != ""){
                alert(msgErr);
                return false;
            }       
            else{
                return true;
            }
        }   
        function show_confirm()
        {
            if(validateForm()==true)
            {
                var x= $("#ID").val();
                if(confirm("Do your want to update "+x+"?")){
                    window.location("ProjectAction.do?method=Update");
                }
                else
                    return false;
            }else{
                return false;
            }            
        }   
    </script>
    <body id="page1">
        <!-- header -->
        <div class="inner_copy"><a href="http://www.site2you.com/">Website Builder</a> <a href="http://www.freetemplatesonline.com/">fto</a> <a href="http://www.websitetemplates.org/">websitetemplates.org</a> <a href="http://www.webdesign.org/website-design">Website Design</a></div> 
        <div id="header">
            <div class="container">
                <!-- .logo -->
                <div class="logo">
                    <a href="index.html"><img src="images/logo1.jpg" alt="" /></a>
                </div>
                <!-- /.logo -->
                <!-- .nav -->
                <ul class="nav">
                    <li><a href="AdminHomepage.jsp">HOME</a></li>
                    <li><html:link href="engineer.do?method=View">ENGINEER</html:link></li>
                    <li><a href="ProjectAction.do?method=View" class="current">PROJECT</a></li>
                    <li><html:link href="TaskAction.do?method=View">TASK</html:link></li>

                </ul>
                <!-- /.nav -->
                <form action="" id="search-form">
                    <fieldset>
                        <p>Back to <a href="login.jsp">log in</a> page.</p>
                    </fieldset>
                </form>

            </div>
        </div>
        <!-- content -->
        <div id="content">
            <div class="container">
                <div class="inside">
                    <div class="wrapper">                        
                        <div class="mainContent">

                            <!-- Our main content begins here -->                            
                            <%
                                java.util.ArrayList<Project> pList = (java.util.ArrayList<Project>) request.getAttribute("prListUpdate");
                                for (Project pr : pList) {%>

                            <table>
                                <html:form action="/ProjectAction">

                                    <tr>
                                        <th scope="col">Project ID:</th>
                                        <td><html:text property="projectID" styleId="ID" value="<%=pr.getProjectID()%>" disabled="true"/></td>
                                    </tr> 
                                    <tr>
                                        <th scope="col">Project Name:</th>
                                        <td><html:text property="projectName" styleId="Name" value="<%=pr.getProjectName()%>"/></td>
                                    </tr>    
                                    <tr>
                                        <th scope="col">Team Leader:</th>
                                        <td>
                                            <html:select property="teamLeader" value="<%= pr.getTeamLeader().getEngineerID()%>">                                                     
                                                <%
                                                    java.util.ArrayList<Engineer> eList = (java.util.ArrayList<Engineer>) request.getAttribute("engineerList");
                                                    if (eList.size() > 0) {
                                                        for (Engineer en : eList) {
                                                %>                                                     }
                                                <html:option value="<%= en.getEngineerID()%>"><%= en.getEngineerID()%> _ <%= en.getFirstName()%> <%= en.getLastName()%></html:option>
                                                <%
                                                        }
                                                    }
                                                %>                                                                                                        
                                            </html:select> 
                                        </td>
                                    </tr> 

                                    <tr>
                                        <th scope="col">Description:</th>
                                        <td><html:textarea property="description" value="<%=pr.getDescription()%>"/></td>
                                    </tr> 
                                    <tr>
                                        <th scope="col">Plan Start Date:</th>
                                        <td><html:text property="planStartDate" styleId="pSD" value="<%=pr.getPlanStartDate()%>"/></td>
                                    </tr> 
                                    <tr>
                                        <th scope="col">Plan End Date</th>
                                        <td><html:text property="planEndDate" styleId="pED" value="<%=pr.getPlanEndDate()%>"/></td>
                                    </tr> 
                                    <tr>
                                        <td><html:submit property="method" onclick="return show_confirm()"><bean:message key="ProjectAction.update"/></html:submit></td>

                                    </tr>
                                </html:form>


                            </table>         
                            <% }%>
                            <!--End of main content-->
                        </div>
                    </div>
                            <div style="text-align: right"><html:link href="ProjectAction.do?method=View">Back to Project Page</html:link></div>
                </div>
            </div>
        </div>
        <!-- footer -->
        <div id="footer">
            <div class="container">
                <div class="inside">
      	Copyright &copy; Team A POSCO-ICT
                </div>
            </div>
        </div>
    </body>
</html>
